from django.conf.urls import url

from rest_framework_jwt.views import obtain_jwt_token
from .views import home,user,image,sku,spu,spec,option,order,permission,group,admin



urlpatterns = [


    url(r'^authorizations/$',obtain_jwt_token),
    url(r'^statistical/total_count/$',home.UserTotalCountView.as_view()),
    url(r'^statistical/day_increment/$',home.DailyUserAddCountAPIVIew.as_view()),
    url(r'^statistical/day_active/$',home.DailyUserActiveCountAPIVIew.as_view()),
    url(r'^statistical/day_orders/$',home.UserDailyOrderCountAPIView.as_view()),
    url(r'^statistical/month_increment/$',home.UserMonthCountAPIView.as_view()),
    url(r'^statistical/goods_day_views/$',home.CategoryCountAPIView.as_view()),

    url(r'^users/$',user.UserListView.as_view()),
    #保存图片数据
    url(r'^skus/simple/$',image.SKUView.as_view()),
    #展示三级分类
    url(r'^skus/categories/$',sku.GoodsCategoryView.as_view()),
    #SPU表名
    url(r'^goods/simple/$',sku.SPUView.as_view()),
    url(r'^goods/(?P<pk>\d+)/specs/$',sku.SPUSpecView.as_view()),

    #获取品牌信息
    url(r'^goods/brands/simple/$',spu.BrandView.as_view()),

    url(r'^goods/channel/categories/(?P<pk>\d+)/$',spu.GoodsCategoryView.as_view()),
    url(r'^goods/channel/categories/$',spu.GoodsCategoryView.as_view()),
    url(r'^goods/specs/simple/$',spu.SPUSpecsView.as_view()),

    #权限路由
    url(r'^permission/content_types/$',permission.ContentTypeAPIView.as_view()),
    url(r'^permission/simple/$',group.SimplePeimissionApiView.as_view()),
    # 获取所有的组
    url(r'^permission/groups/simple/$',admin.GroupListAPIView.as_view()),


]

from rest_framework.routers import DefaultRouter
router = DefaultRouter()
router.register(r'skus/images',image.ImageView)
urlpatterns += router.urls
#注册时前缀后面不加/

#sku的路由
router.register(r'skus',sku.SKUModelViewSet,basename='sku')
urlpatterns += router.urls

# 规格表路由
router.register(r'goods/specs',spec.SpecModelViewSet,basename='spec')
urlpatterns += router.urls

#spu的路由
router.register(r'goods',spu.SPUViewSet,basename='spu')
urlpatterns += router.urls

#规格选项的路由
router.register(r'specs/options',option.OptionsViewSet,basename='option')
urlpatterns += router.urls

#订单路由
router.register(r'orders',order.OrderViewSet,basename='order')
urlpatterns += router.urls

#权限管理路由
router.register(r'permission/perms',permission.PermissionViewSet,basename='permission')
urlpatterns += router.urls

#用户组路由
router.register(r'permission/groups',group.GroupView,basename='group')
urlpatterns += router.urls

#管理员路由
router.register(r'permission/admins',admin.AdminView,basename='group')
urlpatterns += router.urls